import requests
import json

url = "https://rsksapp.rsj.nantong.gov.cn/kw/service/counter/login"# 登录
headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36"
}


data={
    "serial":"10000000a439588e"
    
}

r= requests.post(url,data=data,headers=headers)
# print(r)
json_str =r.content.decode()
json_dict = json.loads(json_str )
token=json_dict['data']
url2 = "https://rsksapp.rsj.nantong.gov.cn/kw/service/counter/getExamList"# 查询考试


headers2 = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36",
    "token": token
}

r2= requests.post(url2,headers=headers2)
json_str2 =r2.content.decode()
json_dict2 = json.loads(json_str2 )
# print(json_dict2['data'][0]['id'])
print(json_dict2['data'])
# json_dict2['data'][0]['id']
url3 = "https://rsksapp.rsj.nantong.gov.cn/kw/service/counter/getSchoolList"#查询考点


headers3 = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36",
    "token": token
}

data3={
    "examId":json_dict2['data'][0]['id']
    
}

r3= requests.post(url3,data=data3,headers=headers3)
json_str3 =r3.content.decode()
json_dict3 = json.loads(json_str3 )
print(json_dict3['data'])


url4 = "https://rsksapp.rsj.nantong.gov.cn/kw/service/counter/getBatch"#查询批次

data4={
    "examSchoolId":json_dict3['data'][0]['id']
}
headers4 = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36",
    "token": token
}

r4= requests.post(url4,data=data4,headers=headers4)
json_str4 =r4.content.decode()
json_dict4 = json.loads(json_str4 )
print(json_dict4['data'])



url5 = "https://rsksapp.rsj.nantong.gov.cn/kw/service/counter/set"#上传计数

print(json_dict3['data'][0]['id'])
print(json_dict4['data'][0]['batch'])
data5={
    # "examSchoolId":json_dict4['data'][0]['id']
    
    'examSchoolId':json_dict3['data'][0]['id'],
    'batch':json_dict4['data'][0]['batch'],
    'kch':'15',
    'count': 29,
    'rewrite': '0' #0为不覆盖，1为覆盖
    
}
headers5 = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36",
    "token": token
}

r5= requests.post(url5,data=data5,headers=headers5)
json_str5 =r5.content.decode()
json_dict5 = json.loads(json_str5 )
print(json_dict5) 

url6 = "https://rsksapp.rsj.nantong.gov.cn/kw/service/counter/getCountedList"#上传计数


data6={
    # "examSchoolId":json_dict4['data'][0]['id']
    
    'examSchoolId':json_dict3['data'][0]['id'],
    'batch':json_dict4['data'][0]['batch']
   
    
}

headers6 = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36",
    "token": token
}

r6= requests.post(url6,data=data6,headers=headers6)
json_str6 =r6.content.decode()
json_dict6 = json.loads(json_str6 )
print(json_dict6) 